[http://episteme.arstechnica.com/eve/forums/a/tpc/f/6330927813/m/312004411831 Shell Script - Sending email attachment - Topic Powered by eve community]
I usually use "mail" for sending plain emails and "mutt" for sending attachments.
echo "This is a message" | mail -s "Subject" foo@bar.com
echo "This is a message w/ attachment" | mutt -a file.gz -s "Subject" foo@bar.com
[http://www.experts-exchange.com/Programming/Programming_Platforms/Unix_Programming/Q_21930761.html Unix Programming: How to Attach file to email sent from shell]
Select whatever you like, each of the belowing does more or less what you want:
metasend -t you@to.tld -s metasend -f yourfile -b -m text/plain -e base64 pine you@to.tld -attach file -I^X elm -s ok you@to.tld -A y echo `cat yourfile`| mutt -a y -s mutt you@to.tld echo "attached file: xxx.txt"|uuenview -b -a -m you@to.tld -s subjet xxx.txt mpack -s "file" yourfile you@to.tld
Another example from: http://www.simplehelp.net/2008/12/01/how-to-send-email-from-the-linux-command-line/#2gQlzZyDAtBCvzhd.99
And if you want mail to read the content from a file: # mail -s “Hello world” you@youremailid.com < /home/calvin/application.log Some other useful options in the mail command are: -s subject (The subject of the mail) -c email-address (Mark a copy to this “email-address”, or CC) -b email-address (Mark a blind carbon copy to this “email-address”, or BCC) Here’s how you might use these options: # echo “Welcome to the world of Calvin n Hobbes” | mail -s “Hello world” calvin@cnh.com -c hobbes@cnh.com -b susie.derkins@cnh.com
Hide Comments